import {createApp} from 'vue'
import {createPinia} from 'pinia'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import router from './router'
import {usePermissStore} from './store/permiss'
import 'element-plus/dist/index.css'
import './assets/css/icon.css'
import {InstallCodeMirror} from 'codemirror-editor-vue3'
import {Splitpanes, Pane} from 'splitpanes'
import 'splitpanes/dist/splitpanes.css'
// @ts-ignore
import JsonEditorVue from 'json-editor-vue3'


const app = createApp(App).use(createPinia())
    .use(router)
    .use(InstallCodeMirror)
    .use(JsonEditorVue)
    .component('Splitpanes', Splitpanes)
    .component('Pane', Pane);
// ....
// app.use(InstallCodeMirror, { componentName: "customName" });

// 注册elementplus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
// 自定义权限指令
const permiss = usePermissStore()
app.directive('permiss', {
    mounted(el, binding) {
        if (binding.value && !permiss.key.includes(String(binding.value))) {
            el['hidden'] = true
        }
    }
})

app.mount('#app')
